package com.js.lottery.domin.strategy.service.draw;

import com.js.lottery.common.Constants;
import com.js.lottery.domin.strategy.service.algorithm.IDrawAlgorithm;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author:JiangSong
 * @Date:2023/11/10
 *
 * 模板模式抽取出来的：数据&配置 支持类
 *
 * 枚举策略Map
 **/


public class DrawConfig {
    @Resource
    private IDrawAlgorithm entiretyRateRandomDrawAlgorithm;

    @Resource
    private IDrawAlgorithm singleRateRandomDrawAlgorithm;

    protected static Map<Integer, IDrawAlgorithm> drawAlgorithmGroup = new ConcurrentHashMap<>();

    // 其中被注解的方法会在该类的构造函数执行之后、依赖注入完成之后被自动调用。
    @PostConstruct
    public void init() {
        drawAlgorithmGroup.put(Constants.StrategyMode.ENTIRETY.getCode(), entiretyRateRandomDrawAlgorithm);
        drawAlgorithmGroup.put(Constants.StrategyMode.SINGLE.getCode(), singleRateRandomDrawAlgorithm);
    }
}
